package cn.com.fig.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface PrivilegeMapper {

	/**
	 * 分页方式查询数据
	 * @return
	 */
	List<Map<String,Object>> listPrivilege(Map<String,String> privilegeMap);
	
	
	String getMaxPrivillegeId(@Param("parentId")String parentId);
	
	@Insert("INSERT INTO	t_privilege(privillegeId,	systemId,	privilName,	priviIcon,	priviUrl,	parentId,priviStatus) VALUES("
			+ "#{privillegeId, jdbcType=VARCHAR},#{systemId, jdbcType=VARCHAR},#{privilName, jdbcType=VARCHAR},"
			+ "#{priviIcon, jdbcType=VARCHAR},#{priviUrl, jdbcType=VARCHAR},#{parentId, jdbcType=VARCHAR},#{priviStatus,jdbcType=CHAR});")
	int insert(Map<String, Object> map);
	
	@Update("UPDATE t_privilege SET systemId = #{systemId, jdbcType=VARCHAR},privilName = #{privilName, jdbcType=VARCHAR},"
			+ "priviIcon=#{priviIcon, jdbcType=VARCHAR},priviUrl = #{priviUrl, jdbcType=VARCHAR},parentId = #{parentId, jdbcType=VARCHAR},priviStatus = #{priviStatus, jdbcType=CHAR}"
			+ " where privillegeId = #{privillegeId, jdbcType=VARCHAR}")
	int update(Map<String, Object> map);
	
	@Delete("delete from t_privilege where privillegeId = #{privillegeId}")
	int delete(@Param("privillegeId") String privillegeId);
}
